package parse;

import ErrorMsg.ErrorMsg;

public class Parse {
  public ErrorMsg errorMsg = new ErrorMsg("");
  public SQL absyn;

  public Parse(String cmdline){
	  byte cmd[] = new byte[cmdline.length()];
	  cmd = cmdline.getBytes();
	  java.io.ByteArrayInputStream input = new java.io.ByteArrayInputStream(cmd);
      Grm parser = new Grm(new Yylex(input), errorMsg);
      /* open input files, etc. here */

      try {
          parser./*debug_*/parse();
      } catch (Throwable e) {
//	e.printStackTrace();
//    	  System.out.println(e.toString());
//    	  throw new Error("syntax error");
    	  throw new Error(e.getMessage());
      } 
      absyn=parser.parseResult;
  }
  
//  public Parse(String filename) {
//      errorMsg = new ErrorMsg.ErrorMsg(filename);
//      {java.io.InputStream inp;
//       try {inp=new java.io.FileInputStream(filename);
//       } catch (java.io.FileNotFoundException e) {
//	 throw new Error("File not found: " + filename);
//       }
//       Grm parser = new Grm(new Yylex(inp,errorMsg), errorMsg);
//      /* open input files, etc. here */
//
//      try {
//          parser./*debug_*/parse();
//      } catch (Throwable e) {
//	e.printStackTrace();
//	throw new Error(e.toString());
//      } 
//      finally {
//         try {inp.close();} catch (java.io.IOException e) {}
//      }
//      absyn=parser.parseResult;
//
//      }
//    }   
}

